package com.rxz.redisdemo.utils;

import java.util.Random;

public class RandomUtils {
    public static String generateRandomNumberString(int length) {
        if (length <= 0) {
            throw new IllegalArgumentException("Length must be a positive integer.");
        }

        Random random = new Random();
        StringBuilder sb = new StringBuilder(length);
        for (int i = 0; i < length; i++) {
            sb.append(random.nextInt(10)); // 生成0到9之间的随机整数并追加到StringBuilder中
        }
        return sb.toString(); // 将StringBuilder转换为字符串并返回
    }
}
